﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="imprimirBoletinsBkp.aspx.cs" Inherits="sistemaAcademicoFinanceiroEscolas.imprimirBoletinsBkp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="css/estilos.css" rel="stylesheet" type="text/css" />
    

</head>


<script type="text/javascript">
function breakeveryheader(){
var thestyle="always";
for (i=0; i<document.getElementsByTagName("div").length; i++)
document.getElementsByTagName("div")[i].style.pageBreakBefore=thestyle
}

</script>



<body>

   <div>

    <% 
        
        Session.Clear();
        
        System.Data.SqlClient.SqlConnection sqlc = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        sqlc.Open();

        System.Data.SqlClient.SqlConnection sqlc2 = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        sqlc2.Open();

        System.Data.SqlClient.SqlConnection sqlc3 = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        sqlc3.Open();

        System.Data.SqlClient.SqlConnection sqlc4 = new System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings["baseDados"]);
        sqlc4.Open();
        
        //Resgatar o nome do aluno
        string sql = "SELECT serie.descricaoSerie as descricaoSerie, serie.codigoSerie as codigoSerie, matricula.codigoTurma, matricula.codigoAnoLetivo as codigoAnoLetivo,  turma.descricaoTurma as descricaoTurma, ";
        sql = sql + "anoLetivo.descricaoAnoLetivo as descricaoAnoLetivo, aluno.codigoAluno as codigoAluno, aluno.nomeAluno as nomeAluno, matricula.codigoMatricula as codigoMatricula FROM aluno INNER JOIN ";
        sql = sql + "matricula ON aluno.codigoAluno = matricula.codigoAluno INNER JOIN serie ";
        sql = sql + "ON matricula.codigoSerie = serie.codigoSerie INNER JOIN turma ON matricula.codigoTurma = turma.codigoTurma INNER JOIN ";
        sql = sql + "anoLetivo ON matricula.codigoAnoLetivo = anoLetivo.codigoAnoLetivo WHERE (matricula.codigoTurma = "+Request.QueryString["codigoTurma"]+") AND ";
        sql = sql + "(matricula.codigoAnoLetivo = " + Request.QueryString["codigoAnoLetivo"] + ")";  
        
        System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, sqlc);
        System.Data.SqlClient.SqlDataReader myReader = cmd.ExecuteReader();

            
        while (myReader.Read())
        
         
            
        {
         
            
        
    %>


        <table width="100%" border="0" style="page-break-before:always">
      <tr>
        <td><table width="100%" border="1" cellpadding="5" cellspacing="0">
          <tr>
            <td width="42%"><img src="images/logomarca.gif" width="233" height="137" /></td>
            <td width="58%" valign="top" class="texto">EDUCANDÁRIO SÃO JUDAS TADEU LTDA (C.G.C 11453651000153)<br />
              RUA PEDRO DE PAULA ROCHA, 277 - NOVO CARMELO - CAMARAGIBE/PE<br />
              Insc SE.C. PORTARIA 4718 - 12/12/1978 - Sob nº P 102016<br />
              Fone/Fax: (81) 34589244 - e-mail: coordenacao@educandariosaojudastadeupe.com.br</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="1" cellpadding="5" cellspacing="0">
          <tr>
            <td width="33%" class="menu"><strong>Matrícula :</strong> <%Response.Write(myReader["codigoMatricula"].ToString()); %></td>
            <td width="29%" class="menu"><strong>Aluno :</strong> <%Response.Write(myReader["nomeAluno"].ToString()); %></td>
            <td width="38%" class="menu"><strong>Número :</strong> <%Response.Write(myReader["codigoAluno"].ToString()); %></td>
          </tr>
          <tr>
            <td class="menu"><strong>Série :</strong> <%Response.Write(myReader["descricaoSerie"].ToString()); %></td>
            <td class="menu"><strong>Turma :</strong> <%Response.Write(myReader["descricaoTurma"].ToString()); %></td>
            <%
            
                DateTime time = DateTime.Now;              // Use current time
                string format = "dd/MM/yyyy";    // Use this format
            
            %>
            <td class="menu"><strong>Data emissão e entrega:</strong> <%Response.Write(time.ToString(format)); %></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>
        
        
               <%  //listar disciplinas da serie
              

            

              //a linha abaixo deve ser definida aqui para que o codigo de pegar a nota do aluno
              //considere uma unidade por vez
              bool encontrouUnidade = false;
              bool primeiroRegistro = true;
              string codigoUnidade = ""; 
            
              string sqlDisciplinas = "select * from disciplina where codigoSerie=" + myReader["codigoSerie"].ToString();

              System.Data.SqlClient.SqlCommand cmdDisciplina = new System.Data.SqlClient.SqlCommand(sqlDisciplinas, sqlc2);
              System.Data.SqlClient.SqlDataReader myReaderDisciplina = cmdDisciplina.ExecuteReader();

              while (myReaderDisciplina.Read())
              {
			  
			  
			  %>
        
        <table width="100%" border="1" cellpadding="5" cellspacing="0">
        

        
          <tr>
            <td width="45%" class="textoNegro"><strong><%Response.Write(myReaderDisciplina["descricaoDisciplina"].ToString());%></strong></td>
            
            
            
            
            <td width="55%" class="textoNegro"><strong> Nota
            
            </strong></td>
            
            

            
            
          </tr>
          
            
			
			
			
                <% 
          

                //listar unidades do ano letivo

                string sqlUnidades = "select * from unidade where codigoAnoLetivo=" + Request["codigoAnoLetivo"].ToString();  
            
            
                System.Data.SqlClient.SqlCommand cmdUnidades = new System.Data.SqlClient.SqlCommand(sqlUnidades, sqlc3);
                System.Data.SqlClient.SqlDataReader myReaderUnidades = cmdUnidades.ExecuteReader();

                while (myReaderUnidades.Read())
                {                  
            
            
             %>  
          
          <tr>
            <td class="textoNegro">
            
            		
            							<%Response.Write(myReaderUnidades["descricaoUnidade"].ToString());%>
            
            </td>
            
            
            
            <td class="textoNegro">
            
            
            
                  <%
            
                    
                  string sqlNota = "select * from nota where codigoAluno=" + myReader["codigoAluno"].ToString() + " and codigoDisciplina=" + myReaderDisciplina["codigoDisciplina"].ToString() + " and codigoUnidade=" + myReaderUnidades["codigoUnidade"].ToString();
                  
                  
                  System.Data.SqlClient.SqlCommand cmdNota = new System.Data.SqlClient.SqlCommand(sqlNota, sqlc4);
                  System.Data.SqlClient.SqlDataReader myReaderNota = cmdNota.ExecuteReader();


                  while (myReaderNota.Read())
                  {                      
                      
                     Response.Write(myReaderNota["notaNota"].ToString());

                  }

                  myReaderNota.Close();
        
        			%>	              

            
                      </td>
          </tr>
          
          <%
		  
		  }

                myReaderUnidades.Close();
		  
		  %>
          

        </table>
        
        
        <%
		
		}

              myReaderDisciplina.Close();
		
		%>

        
        </td>
      </tr>
      <tr>
        <td>.........................................................................................................................................................................................................................................................................................................................................</td>
      </tr>
      <tr>
        <td><table width="100%" border="1" cellpadding="5" cellspacing="0">
          <tr>
            <td width="33%" class="menu"><strong>Matrícula :</strong> <%Response.Write(myReader["codigoMatricula"].ToString()); %></td>
            <td width="29%" class="menu"><strong>Aluno :</strong> <%Response.Write(myReader["nomeAluno"].ToString()); %></td>
            <td width="38%" class="menu"><strong>Número :</strong> <%Response.Write(myReader["codigoAluno"].ToString()); %></td>
          </tr>
          <tr>
            <td class="menu"><strong>Série :</strong> <%Response.Write(myReader["descricaoSerie"].ToString()); %></td>
            <td class="menu"><strong>Turma :</strong> <%Response.Write(myReader["descricaoTurma"].ToString()); %></td>
            
            
            
            
            <td class="menu"><strong>Data emissão e entrega:</strong> <%Response.Write(time.ToString(format)); %></td>
          </tr>
          <tr>
            <td valign="top" class="menu"><strong>Data Devolução  :</strong> </td>
            <td colspan="2" class="menu"><strong>Assinatura do responsável <br />
              <br />
              <br />
            </strong></td>
          </tr>
        </table></td>
      </tr>
    </table>
    
    </div>

    <% 
            
            
            
        }
            

		
		myReader.Close();
        sqlc.Close();
        sqlc2.Close();
        sqlc3.Close();
        sqlc4.Close();
            

        
		
            %>
            
            
            <script language="JavaScript">
			
				self.print();
			
			</script>

    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
